package com.example.customizedgroupmessage;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.view.*;
import android.widget.*;

public class MainActivity extends Activity {

	public static final int REQUEST_CODE_SMSGROUPLISTVIEW=1001;
	public static final int REQUEST_CODE_MAILGROUPLISTVIEW=2001;
	public static final int REQUEST_CODE_TemplateBoxActivity=3001;
	public static final int REQUEST_CODE_CONFIGURE=4001;
	
	DBHelper mHelper;
	SQLiteDatabase db;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		mHelper = new DBHelper(getBaseContext());
		db = mHelper.getWritableDatabase();
		db.execSQL("DELETE FROM sms;");
		db.execSQL("DELETE FROM mail;");
		mHelper.close();
		
		Button btnSMS = (Button)findViewById(R.id.btnSMS);
		btnSMS.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				Intent intent = new Intent(getBaseContext(), SMSGroupListView.class);
				startActivityForResult(intent, REQUEST_CODE_SMSGROUPLISTVIEW);
			}
		});
		Button btnMail = (Button)findViewById(R.id.btnMail);
		btnMail.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				Intent intent = new Intent(getBaseContext(), MailGroupListView.class);
				startActivityForResult(intent, REQUEST_CODE_MAILGROUPLISTVIEW);
			}
		});
		Button btnTemplateBox = (Button)findViewById(R.id.btnTemplateBox);
		btnTemplateBox.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				Intent intent = new Intent(getBaseContext(), TemplateBoxActivity.class);
				startActivityForResult(intent, REQUEST_CODE_TemplateBoxActivity);
			}
		});
		Button btnConfigure = (Button)findViewById(R.id.btnConfigure);
		btnConfigure.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				Intent intent = new Intent(getBaseContext(), Configure.class);
				startActivityForResult(intent, REQUEST_CODE_CONFIGURE);
			}
		});
		
		
		
		
		// sms db 삭제
		//mHelper = new SMSDBHelper(this);
		//db = mHelper.getWritableDatabase();
		//db.execSQL("DELETE FROM sms;");
		//db.execSQL("DROP TABLE IF EXISTS sms");
		//mHelper.close();
	}


	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
